import 'package:dsp_bt_audio/modules/my_home_controller.dart';
import 'package:flutter/material.dart';
import 'package:flutter_kit_plus/flutter_kit.dart';
import 'package:get/instance_manager.dart';

import '../tool/assets.dart';

class DialogWidget extends BaseDialog {
  final DialogWidgetState state = DialogWidgetState();
  DialogWidget({super.key});

  @override
  DialogWidgetState createState() => state;
  @override
  Future<String?> show(BuildContext context, {Function()? completion}) {
    return super.show(context, completion: () => state.controller.currentIndex.value = 100);
  }
}

class DialogWidgetState<T extends DialogWidget> extends BaseDialogState<T> {
  final controller = Get.find<MyHomeController>();
  @override
  void initState() {
    super.initState();
  }

  Widget get child {
    return Container();
  }

  double get height {
    return 0;
  }

  EdgeInsets get padding {
    return EdgeInsets.only(left: 40, right: 40, bottom: 30);
  }

  @override
  Widget buildContent(BuildContext context) {
    return Container(
      height: this.height,
      color: Colors.white,
      child: Stack(
        children: [
          Positioned(
            right: 10,
            top: 10,
            width: 30,
            height: 30,
            child: myIconButton(
              width: 28,
              height: 28,
              iconName: assets.cancel,
              onTap: () {
                Navigator.pop(context);
                controller.currentIndex.value = 100;
              },
            ),
          ),
          Positioned.fill(
            top: 60,
            child: Container(padding: padding, child: child),
          ),
        ],
      ),
    );
  }
}
